import axios from '@/libs/api.request'
/* addRole  新增角色 */
export const addRole = ({
  roleName,
  roleCode,
  roleParentId,
  resourceList,
  remark }) => {
  return axios.request({
    url: '/gas/domain/role/add',
    data: {
      roleName,
      roleCode,
      roleParentId,
      resourceList,
      remark
    },
    method: 'post'
  })
}

/* updateRole 修改角色 */
export const updateRole = ({
  roleName,
  roleParentId,
  resourceList,
  roleId,
  roleCode,
  remark }) => {
  return axios.request({
    url: '/gas/domain/role/update',
    data: {
      roleName,
      resourceList,
      roleParentId,
      roleId,
      roleCode,
      remark
    },
    method: 'post'
  })
}

/* deleteRole 删除角色  */
export const deleteRole = (roleId) => {
  return axios.request({
    url: '/gas/domain/role/delete',
    data: { roleId },
    method: 'post'
  })
}

/*  roleList  角色分页查询  */
export const roleList = ({
  roleParentId,
  roleName,
  pageSize,
  pageNum }) => {
  return axios.request({
    url: '/gas/domain/role/list',
    data: {
      roleParentId,
      roleName,
      pageSize,
      pageNum
    },
    method: 'post'
  })
}

/* getIdRole 根据id查询角色  */
export const getIdRole = (roleId) => {
  return axios.request({
    url: '/gas/domain/role/getRoleById',
    data: { roleId },
    method: 'post'
  })
}

/*  getRoleTree  角色树查询 */
export const getRoleTree = () => {
  return axios.request({
    url: '/gas/domain/role/tree',
    data: {},
    method: 'post'
  })
}

/* bindRoleResource  角色资源绑定  */
export const bindRoleResource = (roleId, resourceList) => {
  return axios.request({
    url: '/gas/domain/role/bindRoleResource',
    data: { roleId, resourceList },
    method: 'post'
  })
}
